﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ecreate.Model;
using Ecreate.Business;
using Ecreate.Data;
namespace Ecreate.Web.popedom.Login
{
    public partial class updpassword : System.Web.UI.Page
    {
        private Ecreate.Popedom.Service.IUserService userService = new Ecreate.Popedom.Service.SpringImpl.UserServiceImpl();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            utility.SessionObject o = (utility.SessionObject)utility.SessionManage.getSessionObject(this);
            if (o.Usertype == utility.LoginUserType.admin)
            {
                string userId = o.Admin.Id;
                Ecreate.Popedom.tSysuser user = userService.getById(userId);
                if (this.txt_oldpassword.Text == "")
                {
                    this.lbl_message.Text = "请输入原密码!";
                    this.lbl_message.Visible = true;
                    return;
                }

                if (this.txt_oldpassword.Text != user.Password)
                {
                    this.lbl_message.Text = "原始密码输入错误!";
                    this.lbl_message.Visible = true;
                    return;
                }
                if (this.txt_password1.Text == "")
                {
                    this.lbl_message.Text = "请输入新密码!";
                    this.lbl_message.Visible = true;
                    return;
                }
                if (this.txt_password2.Text == "")
                {
                    this.lbl_message.Text = "请输入确定密码!";
                    this.lbl_message.Visible = true;
                    return;
                }

                if (this.txt_password1.Text != this.txt_password2.Text)
                {
                    this.lbl_message.Text = "两次输入密码不一致!";
                    this.lbl_message.Visible = true;
                    return;
                }
              
                user.Password = this.txt_password1.Text;
                Ecreate.Popedom.Web.WebResult<Ecreate.Popedom.tSysuser> result = userService.UpdatePassword(user);
                this.lbl_message.Text = result.Message;
                this.lbl_message.Visible = true;


            }
            else
            {



            }
        }
    }
}
